#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    pid_t id = fork();
    if(id == 0)
    {
        //child
        printf("before: CHILD PID:%d, PPID:%d\n", getpid(), getppid());
        sleep(5);
        execl("/usr/bin/ls", "-a", "-l", NULL);
        printf("after: CHILD PID:%d, PPID:%d\n", getpid(), getppid());
        exit(1);
    }
    //father
    pid_t ret = waitpid(id, NULL, 0);
    if(ret > 0)
    {
        printf("wait success, FATHER PID:%d, PPID:%d\n", getpid(), getppid());
    }
    sleep(5);

    return 0;
}

